package cn.seaboot.admin.user.service;

import cn.seaboot.admin.user.dao.RolePermitDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author postm
 */
@Service
public class RolePermitService {

    @Resource
    private RolePermitDao rolePermitDao;

    /**
     * 增
     *
     * @param roleId        角色 ID
     * @param authorityCode 角色 ID
     * @return affected rows
     */
    public int insert(String roleId, String authorityCode) {
        return rolePermitDao.insert(roleId, authorityCode);
    }

    /**
     * 删
     *
     * @param roleId 角色 ID
     * @param permId 权限ID
     * @return affected rows
     */
    public int deleteById(String roleId, String permId) {
        return rolePermitDao.deleteById(roleId, permId);
    }

    /**
     * 删
     *
     * @param roleId 角色 ID
     * @return affected rows
     */
    public int deleteByRoleId(String roleId) {
        return rolePermitDao.deleteByRoleId(roleId);
    }

    /**
     * 删
     *
     * @param permId 权限ID
     * @return affected rows
     */
    public int deleteByPermId(String permId) {
        return rolePermitDao.deleteByPermId(permId);
    }


    /**
     * 清除失效的权限-角色
     *
     * @return affected rows
     */
    public int cleanInvalidRolePermit() {
        return rolePermitDao.cleanInvalidRolePermit();
    }
}
